<%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2019/1/13
  Time: 14:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>员工提成信息</title>
    <jsp:include page="${pageContext.request.contextPath}/common/tag.jsp"/>
</head>
    <script>
        $(function () {
            /*员工提成表*/
            $("#tcstaff").bootstrapTable({
                url:'${pageContext.request.contextPath}/ticheng/query',
                //toolbar : '#add#delete',
                height:300,
                pagination:true,//开启分页
                sidePagination:'server',//服务器分页
                pageSize:4,//页面显示的行数
                pageList:[2,4,8,16],
                queryParams:function(params){
                    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        limit: params.limit,  //页面大小
                        offset: params.offset, //页码
                        name : $("#yname").val()
                    };
                    return temp;
                },
                columns: [
                    {checkbox:true},
                    {field:'staff.yId',title:'员工编号',align:'center'},
                    {field:'staff.yName',title:'员工姓名',align:'center'},
                    {field:'staff.ySex',title:'性别',align:'center'},
                    {field:'staff.yDate',title:'入职日期',align:'center'},
                    /*{field:'shopName',title:'所属店铺',align:'center'},*/
                    {field:'staff.yPhone',title:'电话',align:'center'},
                    {field:'staff.yAddress',title:'地址',align:'center'},
                    {field:'staff.yEmail',title:'邮箱',align:'center'},
                    {field:'tcMoney',title:'提成金额',align:'center'},
                    /*{title:'操作',align:'center',
                        formatter: function (value,row,index) {
                            return  "<button class=\"btn btn-primary\" data-toggle=\"modal\" href=\"#edit\" onclick='edit(("+row.yId+"))'><span class=\"glyphicon glyphicon-edit\"></span>修改</button>&nbsp;&nbsp;<button class=\"btn btn-primary\" onclick='shanchu("+row.yId+")'><span class=\"glyphicon glyphicon-trash\"></span>&nbsp;&nbsp 删除</button>";
                        }
                    }*/
                ],
                onClickRow : function(row, $element){
                    var index = $element.data('index');
                    $("#tcstaff").bootstrapTable("uncheckAll");
                    //console.log(row);
                    //选中要修改的行
                    $("#tcstaff").bootstrapTable("check",index);
                    console.log(row);
                    $.post('${pageContext.request.contextPath}/ticheng/getxiaoshou',{"yid":row.staffid},function (data) {
                        console.log(data);
                        $("#xsdaninfo").bootstrapTable('load',data);
                    })
                }
            });
            /*员工销售表*/
            $("#xsdaninfo").bootstrapTable({
                url:'',
                height:500,
                pageSize:4,//页面显示的行数
                pageList:[2,4,8,16],
                columns: [
                    {checkbox:true},
                    {field:'dnumbers',title:'订单号',align:'center'},
                    {field:'ddate',title:'订单日期',align:'center'},
                    {field:'member.name',title:'购买人',align:'center'},
                    {field:'dnum',title:'购买总数量',align:'center'},
                    {field:'dzhehou',title:'总金额',align:'center'},
                    {field:'beizhu',title:'备注',align:'center'},
                    {field:'staff.yName',title:'经办人',align:'center'}
                ]
            });
        })
    </script>
<body style="margin:20px 10px;overflow-y: hidden">
    <div>
        <form class="form-inline" style="text-align: right;margin-top: 20px;">
            <div class="form-group">
                <label for="yname">员工姓名：</label>&nbsp;
                <input type="text" class="form-control" id="yname" placeholder="请输入用户名" style="">
            </div>
            <button onclick="sousuo();" class="btn btn-primary" type="button"><span class="glyphicon glyphicon-search"></span>搜索</button>
        </form>
        <table id="tcstaff"></table>

        <table id="xsdaninfo"></table>
    </div>
</body>
<script>
    function  sousuo() {
        //返回表格的options
        var options = $("#tcstaff").bootstrapTable("getOptions")
        var limit = options.pageSize;
        var offset = (options.pageNumber-1)*limit;
        var yName = $("#yname").val();
        $.post("${pageContext.request.contextPath}/ticheng/query",{'name':yName,'offset':offset,'limit':limit},function (data) {
            // var mydata = eval("("+data+")") ;
            //重新绑定表格数据
            $("#tcstaff").bootstrapTable('load',data) ;
        })
    }
</script>
</html>
